﻿@model Web.Models.AdminNavigation
@{
    ViewBag.Title = "Edit";
}
@section head{
    <link href="~/content/layuiadmin/lib/formSelects/formSelects-v4.css" rel="stylesheet" />
}
<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">
    @Html.AntiForgeryToken()

    @Html.HiddenFor(model => model.Id,new{Value=Model?.Id ?? 0})

    <div class="layui-form-item">
        @Html.LabelFor(model => model.ParentId, new { @class = "layui-form-label", @for = "ParentId" })
        <div class="layui-input-block">
            @Html.DropDownListFor(model => model.ParentId, null, "无父级", new { autocomplete = "off", @class = "layui-input", xm_select_radio = "", xm_select = "select_parentId" })
        </div>
    </div>

    <div class="layui-form-item">
        @Html.LabelFor(model => model.Text, new { @class = "layui-form-label", @for = "Text" })
        <div class="layui-input-block">
            @Html.TextBoxFor(model => model.Text, new { lay_verify = "required", autocomplete = "off", @class = "layui-input" })
        </div>
    </div>

    <div class="layui-form-item">
        @Html.LabelFor(model => model.Action, new { @class = "layui-form-label", @for = "Action" })
        <div class="layui-input-block">
            @Html.TextBoxFor(model => model.Action, new {  autocomplete = "off", @class = "layui-input" })
        </div>
    </div>

    <div class="layui-form-item">
        @Html.LabelFor(model => model.Controller, new { @class = "layui-form-label", @for = "Controller" })
        <div class="layui-input-block">
            @Html.TextBoxFor(model => model.Controller, new {  autocomplete = "off", @class = "layui-input" })
        </div>
    </div>

    <div class="layui-form-item">
        @Html.LabelFor(model => model.Icon, new { @class = "layui-form-label", @for = "Icon" })
        <div class="layui-input-block">
            @Html.TextBoxFor(model => model.Icon, new { autocomplete = "off", @class = "layui-input" })
        </div>
    </div>

    <div class="layui-form-item">
        @Html.LabelFor(model => model.OrderId, new { @class = "layui-form-label", @for = "OrderId" })
        <div class="layui-input-block">
            @Html.TextBoxFor(model => model.OrderId, new { lay_verify = "required", autocomplete = "off", @class = "layui-input" })
        </div>
    </div>

    <div class="layui-form-item">
        @Html.LabelFor(model => model.Param, new { @class = "layui-form-label", @for = "Param" })
        <div class="layui-input-block">
            @Html.TextBoxFor(model => model.Param, new { autocomplete = "off", @class = "layui-input" })
        </div>
    </div>

    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-submit" id="layuiadmin-app-form-submit" value="确认添加">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-edit" id="layuiadmin-app-form-edit" value="确认编辑">
    </div>
</div>

@section scripts
{
    <script>
        layui.config({
            base: '/Content/LayuiAdmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
            , formSelects: '../lib/formSelects/formSelects-v4' //美化select
            }).use(['index', 'form', 'laydate','formSelects'], function () {
            var $ = layui.$
                , form = layui.form
                , admin = layui.admin
                //, formSelects = layui.formSelects
                , laydate = layui.laydate;

				laydate.render({
                elem: '#CreateTime',
                type: 'datetime'
            });
									            //监听提交
            form.on('submit(layuiadmin-app-form-edit)', function (data) {
                var field = data.field; //获取提交的字段
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                //提交 Ajax 成功后，关闭当前弹层并重载表格
                admin.req({
                    url: '@(Url.Action("Edit"))'
                    , type: "POST"
                    , data: field
                    , done: function (res) {
                        if (res.statusCode === 0) {
                            parent.layui.table.reload('LAY-app-content-list'); //重载表格
                            parent.layer.close(index); //再执行关闭
                            parent.parent.layer.msg(res.message, { offset: '15px', icon: 1 });
                        } else {
                            parent.parent.layer.msg(res.message, { offset: '15px', icon: 5 });
                        }
                    },
                    error: function (res) {
                        console.log('error='+res);
                    }
                });
            });
        })
    </script>
}

